package com.xhwl.centiotdata.pushtrigger.firefighting;

import com.alibaba.fastjson.JSON;
import com.xhwl.centiotdata.handler.firefighting.impl.FirefightingHuaWeiIoTDAHandler;
import com.xhwl.centiotdata.pojo.dto.firefighting.FireFireHydrantAlarm;
import com.xhwl.common.dto.cent.device.iot.DeviceServiceBody;
import com.xhwl.common.dto.cent.device.iot.IotDeviceJson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author： lianghz
 * @Description：
 * @Date 2022/01/12/ 10:39
 */
@Slf4j
@RestController
public class FireHydrantCallback {

    @Autowired
    FirefightingHuaWeiIoTDAHandler handler;

    @PostMapping("/firefighting/huawei-iotda/fire-hydrant/{projectId}")
    public void pushFireHydrant(@RequestBody IotDeviceJson<DeviceServiceBody<FireFireHydrantAlarm>> data, @PathVariable Integer projectId) {
        log.debug("pushFireHydrant: " + JSON.toJSONString(data));
        handler.pushFireHydrant(data, projectId);
    }

}
